home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: AmIrc2Html v1.1 (01-Sep-98) by D.F. Duck http://www.wordbench.com/dfd/
- Converts AmIRC buffer/log to HTML.
- */
- options results
- parse arg infile' 'outfile' "'title'" 'flags
-
- if length(infile)=0 | infile='?' then do
- ver=sourceline(2)
- parse var ver verl') 'verr
- say '0C'x' 'strip(verl,'L',' $VER:')')'
- say ' 'strip(verr)
- say ' 'strip(sourceline(3))'0A'x
- say 'Usage: rx AmIrc2Html <infile> <outfile> <"title text"> [-f-u]'
- say
- say ' infile = AmIRC log file to parse.'
- say
- say ' outfile = File to write output to.'
- say
- say ' "title text" = your html title text enclosed inside'
- say ' double quote marks.'
- say
- say ' -f = filter out private /msg''s, /notice''s, and /whois'
- say ' replies.'
- say ' -u = URL Grabber; add html links to url''s.'
-
- exit
- end
-
- signal on break_c
- signal on syntax
-
- if length(strip(title))=0 then title='My AmIRC Log'
- title=strip(title,'T','"')
- if upper(right(outfile,5))~='.HTML' then outfile=outfile'.html'
- call clear_vars
- c=0
- nopriv=0 ;if pos('-F',upper(flags))>0 then nopriv=1
- urlgrab=0 ;if pos('-U',upper(flags))>0 then urlgrab=1
-
- if open(x,infile,'R') then do
- call open(y,outfile,'W')
- call writech(stdout,'Working..')
- call writeln(y,'<HTML><HEAD><TITLE>'title'</TITLE></HEAD>')
- call writeln(y,'<CENTER><H1>'title'</H1></CENTER>')
- call writeln(y,'<BODY>')
- call writeln(y,'<HR>')
- call writeln(y,'<PRE>')
- do until eof(x)
- line = readln(x)
- line = translate(line,' ',' ')
- parse var line first' 'rest
- if length(rest)=0 then iterate
- c=c+1
-
- /* filter out private messages */
- ok=1
- if (nopriv) then do
- firstL=left(first,1)
- firstR=right(first,1)
- select
- when firstL='*' & firstR='*' then ok=0
- when firstL='>' & firstR='<' then ok=0
- when firstL='«' & firstR='»' then do
- if pos('Whois',first)>0 then ok=0
- if pos('Notify',first)>0 then ok=0
- end
- otherwise nop
- end
- end
- if ~(ok) then iterate
-
-
- if left(first,1)='<' & right(first,1)='>' then do
- first=strip(first,'L','<')
- first=strip(first,'T','>')
- end
-
- /* filter out <>'s so it doesn't hose the html display */
- p=''
- do until p=0
- p=pos('<',rest)
- if p>0 then do
- restr=left(rest,p-1)
- restl=right(rest,length(rest)-(length(restr)+1))
- rest=restr'<'restl
- end
- end
- p=''
- do until p=0
- p=pos('>',rest)
- if p>0 then do
- restr=left(rest,p-1)
- restl=right(rest,length(rest)-(length(restr)+1))
- rest=restr'>'restl
- end
- end
-
- if length(rest)>65 then line.1=left(rest,lastpos(' ',rest,66))
- else line.1=rest
-
- if length(rest)>length(line.1) then line.2=right(rest,length(rest)-length(line.1))
-
- /* call url checker */
- if (urlgrab) then line.1=urlcheck(line.1)
-
- call writeln(y,left(first,10)'|'line.1)
-
- if length(line.2)>0 then do i = 2 to 6
- j=i+1
- if length(line.i)>66 then do
- line.j = right(line.i,length(line.i)-lastpos(' ',line.i,66))
- line.i = left(line.i,lastpos(' ',line.i,66))
- end
- /* call url checker */
- if (urlgrab) then line.i=urlcheck(line.i)
- if length(line.i)>0 then call writeln(y,left(' ',10)'|'line.i)
- end
-
- call clear_vars
- if c/50 = c%50 then call writech(stdout,'.')
- end
- call close(x)
- call writeln(y,'</PRE>')
- call writeln(y,'<P><HR>')
- call writeln(y,'<CENTER><FONT SIZE=-1>Page created with AmIrc2Http 1.0 by <a href="http://www.wordbench.com/dfd/">D.F. Duck</a></FONT></CENTER>')
- call writeln(y,'</BODY')
- call writeln(y,'</HTML>')
- call close(y)
- call writeln(stdout,' All done!')
- end
- else say 'Error opening "'infile'"'
- exit
-
- urlcheck:
- parse arg text
- utext=upper(text)
- if pos('HTTP://',utext)>0 | pos('HTTPS://',utext)>0 | pos('WWW.',utext)>0 then text=urlgrabber(text)
- if pos('&',text)>0 then text=insert('amp;',text,pos('&',text))
- return text
-
- urlgrabber:
- parse arg text
- p=pos('HTTP://',utext)
- if p>0 then do
- l = left(text,p-1)
- t = right(text,length(text)-(p-1))
- parse var t w' 'r
- text=l'<A HREF="'w'">'w'</A> 'r
- return text
- end
- p=pos('HTTPS://',utext)
- if p>0 then do
- l = left(text,p-1)
- t = right(text,length(text)-(p-1))
- parse var t w' 'r
- text=l'<A HREF="'w'">'w'</A> 'r
- return text
- end
- p=pos('WWW.',utext)
- if p>0 then do
- l = left(text,p-1)
- t = right(text,length(text)-(p-1))
- parse var t w' 'r
- if length(w)=4 then break
- text=l'<A HREF="http://'w'">'w'</A> 'r
- end
- return text
-
- clear_vars:
- do i = 1 to 7
- line.i=''
- end
- return
-
- break_c:
- call close(x)
- call close(y)
- say 'CTRL-C detected, exiting.'
- exit
-
- syntax:
- say 'Syntax error line 'sigl' :'errortext(rc)
- say '> 'sourceline(sigl)
- exit
-